import pandas as pd
import requests

df = pd.read_excel("/home/zhengzhenzhuang/test/2005-2023-08-09没有总结-new.xlsx")
data_list = df.values.tolist()

def qwenapi(fileName, question):
    # 接口URL
    url = 'http://127.0.0.1:8099/qwen2/api'
    # 发送GET请求
    response = requests.get(url)
    # 检查响应状态
    """
    if response.status_code == 200:
        # 获取响应内容（JSON格式）
        data = response.json()
        print(data)
    else:
        print('Failed to retrieve data: ', response.status_code)
    """
    # 发送POST请求
    payload = {'fileName': fileName, 'question': question}
    response = requests.post(url, data=payload)
    return response
    """
    # 检查响应并获取结果
    if response.status_code == 200:
        print('Success: ', response.json())
    else:
        print('Failed to post data: ', response.status_code)
    """


n = 0
for mylist in data_list:
    n = n + 1
    print(mylist[0])
    print(mylist[1])
    output = qwenapi(mylist[0], mylist[2])
    print(output)
    mylist[2] = output
    if n % 10 == 0:
        print(n)
        print("excel")
        df_from_list = pd.DataFrame(data_list)
        df_from_list.to_excel('/home/zhengzhenzhuang/test/2005-2023-08-09没有总结.xlsx', index=False)
    print()

df_from_list = pd.DataFrame(data_list)
df_from_list.to_excel('C/home/zhengzhenzhuang/test/2005-2023-08-09没有总结.xlsx', index=False)
